package com.mall.product.server.controller;

import com.mall.common.core.domain.Result;
import com.mall.common.security.annotation.RequiresPermissions;
import com.mall.product.common.domain.PmsSkuInfo;
import com.mall.product.common.domain.PmsSpuInfo;
import com.mall.product.server.service.impl.PmsSkuInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("skuInfo")
public class PmsSkuInfoController {

    @Autowired
    private PmsSkuInfoServiceImpl pmsSkuInfoService;


    /**
     * 根据商户Id查看商品列表
     */
    @GetMapping("/findByShopId/{shopId}")
    public List<PmsSkuInfo> findByShopId(@PathVariable Long shopId) {
        List<PmsSkuInfo> pmsSkuInfos = pmsSkuInfoService.selectByShopId(shopId);
        return pmsSkuInfos;
    }

    /**
     * 获取sku信息详细信息
     */
    @GetMapping("/{skuId}")
    public Result<PmsSkuInfo> getInfo(@PathVariable("skuId") Long skuId)
    {
        return Result.success(pmsSkuInfoService.selectPmsSkuInfoBySkuId(skuId));
    }
}
